/**
 * author:Administrator
 * date:2015/7/27
 * desc:TODO
 */

"use strict";

let mongoose = require('mongoose');
let Schema = mongoose.Schema;
let UserSchema = new Schema({
    uid: {type: Number, index: true, unique: true},
    roleName: String,
    createdAt: {type: Date, default: Date.now},
    updatedAt: Date
});

UserSchema.pre('save', function (next) {
    if (!this.updatedAt) {
        this.updatedAt = new Date();
    }
    next();
});

// 指定collection name，默认是复数
var user = mongoose.model('userRole', UserSchema, 'userRole');
exports = module.exports = user;